package net.jeeshop.services.manage.system.impl;


import net.jeeshop.core.Services;
import net.jeeshop.core.dao.BaseDao;
import net.jeeshop.core.dao.page.PagerModel;
import net.jeeshop.core.system.bean.User;
import net.jeeshop.services.common.Poverty;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by xvhuichuang on 2017/6/26.
 */
@Service
public class PovertyService implements Services<Poverty> {
    @Resource
    private BaseDao baseDao;

    @Override
    public int insert(Poverty poverty) {
        return baseDao.insert("poverty.insert", poverty);
    }

    @Override
    public int delete(Poverty poverty) {
        return baseDao.delete("poverty.delete", poverty);
    }

    @Override
    public int deletes(String[] ids) {
        Poverty poverty = new Poverty();
        for (int i = 0; i < ids.length; i++) {
            poverty.setId(ids[i]);
            delete(poverty);
        }
        return 0;
    }

    @Override
    public int update(Poverty poverty) {
        return baseDao.update("poverty.update", poverty);
    }

    @Override
    public Poverty selectOne(Poverty poverty) {
        return (Poverty) baseDao.selectOne("poverty.selectOne",poverty);
    }

    @Override
    public Poverty selectById(String id) {
        Poverty poverty = new Poverty();
        poverty.setId(id);
        return selectOne(poverty);
    }

    public Poverty selectOneByPersonCode(String personCode) {
        Poverty poverty = new Poverty();
        poverty.setPersonCode(personCode);
        return (Poverty) baseDao.selectOne("poverty.selectList", poverty);
    }

    @Override
    public PagerModel selectPageList(Poverty poverty) {
        return baseDao.selectPageList("poverty.selectPageList",
                "poverty.selectPageCount", poverty);
    }

    @Override
    public List<Poverty> selectList(Poverty poverty) {
        if (poverty == null)
            return baseDao.selectList("poverty.selectList");
        return baseDao.selectList("poverty.selectList", poverty);
    }
}
